//
//  JwSkinerEx.m
//  JwPack
//
//  Created by 陈警卫 on 2024-08-06.
//

#import "JwSkinerEx.h"
#import <UIKit/UIKit.h>
#import "JwSkinerColor.h"

@implementation JwSkinerEx

- (instancetype)init {
    self = [super init];
    if (self) {
        [self setupView];
    }
    return self;
}

- (void)setupView {
    
    JwSkiner *skiner = [JwSkiner shared];
    skiner.colorClass = [JwSkinerColor class];
    //skiner.colorClass = [UIColor class];
    
    
    UIView *view = [[UIView alloc] init];
    // 直接赋值
    view.backgroundColor = [JwSkinerColor jw_theme].color;
    
    //view.backgroundColor = [UIColor jw_theme].color;
    
    // 设置key 会被动刷新
    view.jw_backgroundColorKey = [JwSkinerColor jw_theme].key;
    
    // 设置回调(处理刷新)
    __weak typeof(view) wview = view;
    view.jw_didSkinerBlock = ^(id  _Nonnull sender) {
#warning 不要在 jw_didSkinerBlock 回调方法中设置 (jw_backgroundColorKey) 等key 会死循环
        wview.backgroundColor = [JwSkinerColor jw_theme].color;
    };
    
}

@end
